﻿namespace SsisLdapSource.InstantiationTime
{
    using System.Collections.Generic;

    public class CustomProperties
    {
        private readonly List<CustomPropertyInfo> customProperties;
 
        private readonly CustomPropertyInfo hostOrDomainNameProperty = new CustomPropertyInfo(
           "HostOrDomainName",
           "Specify name of an LDAP Host or Domain",
           CustomPropertiesDefaultValueFactory.DomainName,
           false,
           false);

        private readonly CustomPropertyInfo portNumberProperty = new CustomPropertyInfo(
           "PortNumber",
           "Specify port number on which LDAP server is listening",
           389,
           false,
           false);

        private readonly CustomPropertyInfo baseDNProperty = new CustomPropertyInfo(
           "BaseDN",
           "Specify Base of the LDAP Search, (ex. cn=Users,ou=fabrikam,dc=com)",
           CustomPropertiesDefaultValueFactory.GetBaseDN(),
           false,
           false);

        private readonly CustomPropertyInfo useTaskSecurityContextProperty = new CustomPropertyInfo(
           "UseTaskSecurityContext",
           "Specify whether the component should utilize the security context of the task",
           true,
           false,
           false);

        private readonly CustomPropertyInfo useSSLProperty = new CustomPropertyInfo(
           "UseSSL",
           "Specify whether the component should utilize SSL.",
           false,
           false,
           false);

        private readonly CustomPropertyInfo connectionAccountNameProperty = new CustomPropertyInfo(
            "ConnectionAccountName",
            "Specify LDAP Connection Account, if using Active Directory specify account's UPN (ex. administrator@fabrikam.com)",
            string.Empty,
            false,
            false);

        private readonly CustomPropertyInfo connectionAccountPasswordProperty = new CustomPropertyInfo(
            "ConnectionAccountPassword",
            "Specify password for the connection account",
            string.Empty,
            true,
            false);

        private readonly CustomPropertyInfo authenticationTypeProperty = new CustomPropertyInfo(
            "AuthenticationType",
            "Specify authentication type. Currently, only NEGOTIATE and BASIC types are supported",
            "NEGOTIATE",
            false,
            false);

        private readonly CustomPropertyInfo searchFilterProperty = new CustomPropertyInfo(
            "SearchFilter",
            "Specify LDAP Search Filter",
            "(&(!objectClass=computer)(|(objectClass=user)(objectClass=group)))",
            false,
            false);

        private readonly CustomPropertyInfo attributesToLoadProperty = new CustomPropertyInfo(
           "AttributesToLoad",
           "Specify AD attributes to load, use ',' to provide multiple attributes. Note: objectGUID is mandatory attribute",
            new[] { "distinguishedName", "objectCategory", "objectGUID", "displayName", "member" },
            false,
            true);

        private readonly CustomPropertyInfo includeObjectOwnerInfoProperty = new CustomPropertyInfo(
          "IncludeObjectOwnerInfo",
          "Indicate whether you want object owner info to be include in the query result. This feature is only supported with Active Directory Domain Services and Active Directory Lightweight Services",
           false,
           false,
           false);

        private readonly CustomPropertyInfo domainScopeEnforcedProperty = new CustomPropertyInfo(
          "DomainScopeEnforced",
          "Indicate whether you referals need to be chased by the query. This must be set to TRUE when connecting to Active Directory Domain Services and Active Directory Lightweight Services. When connecting to EDirectory set this value to FALSE",
           true,
           false,
           false);

        private readonly CustomPropertyInfo int64EncodedDateTimeAttributesProperty = new CustomPropertyInfo(
           "Int64EncodedDateTimeAttributes",
           "Specify AD attributes which contain int64 encoded DateTime values (ex. PwdLastSet), use ',' to provide multiple attributes.",
            new[] { "lastLogonTimestamp", "lastLogon", "pwdLastSet", "accountExpires" },
            false,
            true);

        private readonly CustomPropertyInfo guidEncodedBinaryAtrributesProperty = new CustomPropertyInfo(
           "GuidEncodedBinaryAttributes",
           "Specify AD attributes which represent GUID encoded binary data (ex. objectGUID), use ',' to provide multiple attributes.",
            new[] { "objectGUID" },
            false,
            true);

        private readonly CustomPropertyInfo sidEncodedBinaryAtrributesProperty = new CustomPropertyInfo(
           "SidEncodedBinaryAttributes",
           "Specify AD attributes which represent SID encoded binary data (ex. objectSID), use ',' to provide multiple attributes.",
            new[] { "objectSID" },
            false,
            true);

        private readonly CustomPropertyInfo stringEncodedIntAttributesProperty = new CustomPropertyInfo(
           "StringEncodedIntAttributes",
           "Specify AD attributes which represent String encoded Integer values (ex. userAccountControl), use ',' to provide multiple attributes.",
            new[] { "userAccountControl" },
            false,
            true);

        private readonly CustomPropertyInfo attributesWhichMayRequireExpansionProperty = new CustomPropertyInfo(
           "AttributesWhichMayRequireExpansion",
           "When the number of values in a multivalue attribute exceeds a certain threshold," +
           " LDAP directories may require query expansion to bring back all the values." +
           " Specify AD attributes which may contain more than 1000 values (ex. member), use ',' to provide multiple attributes.",
            new[] { "member" },
            false,
            true);

        private readonly CustomPropertyInfo ldapPrimaryKeyEquivalentProperty = new CustomPropertyInfo(
           "LdapPrimaryKeyEquivalent",
           "LDAP attribute, which is garanteed to be unique within the directory (ex. objectGUID, distinguishedName). " +
           "This attribute is mandatory, and is used to link mutli-valiued attributes to the parent record.",
            "objectGUID",
            false,
            false);

        private readonly CustomPropertyInfo pageSizeProperty = new CustomPropertyInfo(
            "PageSize",
            "Specify Active Directory Query Page size",
            1000,
            false,
            false);

         public CustomProperties()
         {
             customProperties = new List<CustomPropertyInfo>
                 {
                     hostOrDomainNameProperty,
                     portNumberProperty,
                     baseDNProperty,
                     useTaskSecurityContextProperty,
                     useSSLProperty,
                     connectionAccountNameProperty,
                     connectionAccountPasswordProperty,
                     authenticationTypeProperty,
                     searchFilterProperty,
                     includeObjectOwnerInfoProperty,
                     domainScopeEnforcedProperty,
                     attributesToLoadProperty,
                     int64EncodedDateTimeAttributesProperty,
                     guidEncodedBinaryAtrributesProperty,
                     sidEncodedBinaryAtrributesProperty,
                     stringEncodedIntAttributesProperty,
                     attributesWhichMayRequireExpansionProperty,
                     ldapPrimaryKeyEquivalentProperty,
                     pageSizeProperty
                 };
         }

        public IEnumerable<CustomPropertyInfo> GetCustomProperties
        {
            get { return customProperties; }
        }
    }
}
